﻿using LvcChong.EventDto;
using System.ComponentModel;
using System.Net;
using System.Reflection;
using System.Web;

namespace LvcChong
{
    internal class DataProvider
    {
        private CookieCollection _cookieCollection = new CookieCollection();
        public CookieCollection CookieCollection { get { return _cookieCollection; } }

        private string _host = string.Empty;

        public event EventHandler<DataVItemEventArgs>? OnSucceed;

        public event EventHandler<ExceptionEventArgs>? OnException;

        public event EventHandler<DataGridItemEventArgs>? OnDataGridRefreshed;


        public DataProvider(string host)
        {
            _host = host;
        }

        private void SetHeaders(ApiRequest request)
        {
            var dic = new Dictionary<string, string>
            {
                { "Accept", "application/json, text/javascript, */*; q=0.01" },
                { "Accept-Encoding", "gzip, deflate, br, zstd" },
                { "Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6" },
                { "X-Requested-With", "XMLHttpRequest" },
                { "Referer", "https://www.lvcchong.com/orderQuery/" },
            };
            request.AddHeaders(dic);
        }

        public QueryOutputT<List<PromotionUserListOutput>> PromotionUserListQuery(PromotionUserListInput input)
        {
            var request = new ApiRequest($"{_host}/api/carServiceFeePromotion/userRelationList", contentType: "application/x-www-form-urlencoded; charset=UTF-8", method: RestSharp.Method.Post);
            request.AddBody(ConvertToQueryString(input));
            request.AddCookies(_cookieCollection);
            var ret = request.Invoke();
            if (!ret.IsSuccess) return default;

            var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryOutputT<List<PromotionUserListOutput>>>(ret.Data);
            if (obj?.Code == 0)
            {
                _cookieCollection = request.Client.Options.CookieContainer.GetAllCookies();
                return obj;
            }
            return default;
        }

        public QueryOutputT<List<PromotionListOutput>> PromotionListQuery(PromotionListInput input)
        {
            var request = new ApiRequest($"{_host}/api/carServiceFeePromotion/list", contentType: "application/x-www-form-urlencoded; charset=UTF-8", method: RestSharp.Method.Post);
            request.AddBody(ConvertToQueryString(input));
            request.AddCookies(_cookieCollection);
            var ret = request.Invoke();
            if (!ret.IsSuccess) return default;

            var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryOutputT<List<PromotionListOutput>>>(ret.Data);
            if (obj?.Code == 0)
            {
                _cookieCollection = request.Client.Options.CookieContainer.GetAllCookies();
                return obj;
            }
            return default;
        }

        public QueryOutputT<List<UserInfoOutput>> UserListQuery(UserListInput input)
        {
            var request = new ApiRequest($"{_host}/user/list", contentType: "application/x-www-form-urlencoded; charset=UTF-8", method: RestSharp.Method.Post);
            request.AddBody(ConvertToQueryString(input));
            request.AddCookies(_cookieCollection);
            var ret = request.Invoke();
            if (!ret.IsSuccess) return default;

            var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryOutputT<List<UserInfoOutput>>>(ret.Data);
            if (obj?.Code == 0)
            {
                _cookieCollection = request.Client.Options.CookieContainer.GetAllCookies();
                return obj;
            }
            return default;
        }

        public QueryOutputT<List<VehicleInfoOutput>> VehicleListQuery(VehicleListInput input)
        {
            var request = new ApiRequest($"{_host}/api/vehicle/getVehicleList", contentType: "application/x-www-form-urlencoded; charset=UTF-8", method: RestSharp.Method.Post);
            request.AddBody(ConvertToQueryString(input));
            request.AddCookies(_cookieCollection);
            var ret = request.Invoke();
            if (!ret.IsSuccess) return default;

            var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryOutputT<List<VehicleInfoOutput>>>(ret.Data);
            if (obj?.Code == 0)
            {
                _cookieCollection = request.Client.Options.CookieContainer.GetAllCookies();
                return obj;
            }
            return default;
        }

        public QueryOutputT<List<UserInfoOutput>> UserInfoQuery(UserInfoInput input)
        {
            var request = new ApiRequest($"{_host}/customerQuery/userInfo", contentType: "application/x-www-form-urlencoded; charset=UTF-8", method: RestSharp.Method.Post);
            request.AddBody(ConvertToQueryString(input));
            request.AddCookies(_cookieCollection);
            var ret = request.Invoke();
            if (!ret.IsSuccess) return default;

            var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryOutputT<List<UserInfoOutput>>>(ret.Data);
            if (obj?.Code == 0)
            {
                _cookieCollection = request.Client.Options.CookieContainer.GetAllCookies();
                return obj;
            }
            return default;
        }

        public QueryOutputT<List<OrderQueryOutput>> ChargeQuery(UserInfoInput input)
        {
            var request = new ApiRequest($"{_host}/customerQuery/charge", contentType: "application/x-www-form-urlencoded; charset=UTF-8", method: RestSharp.Method.Post);
            request.AddBody(ConvertToQueryString(input));
            request.AddCookies(_cookieCollection);
            var ret = request.Invoke();
            if (!ret.IsSuccess || ret.Data == "") return default;

            var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryOutputT<List<OrderQueryOutput>>>(ret.Data);
            if (obj?.Code == 0)
            {
                _cookieCollection = request.Client.Options.CookieContainer.GetAllCookies();
                return obj;
            }
            return default;
        }

        public QueryOutputT<List<OrderQueryOutput>> OrderQuery(OrderQueryInput input)
        {
            var request = new ApiRequest($"{_host}/api/big/orderQuery", contentType: "application/x-www-form-urlencoded; charset=UTF-8", method: RestSharp.Method.Post);
            request.AddBody(ConvertToQueryString(input));
            request.AddCookies(_cookieCollection);
            var ret = request.Invoke();
            if (!ret.IsSuccess) return default;

            var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<QueryOutputT<List<OrderQueryOutput>>>(ret.Data);
            if (obj?.Code == 0)
            {
                _cookieCollection = request.Client.Options.CookieContainer.GetAllCookies();
                return obj;
            }
            throw new Exception(obj.Msg);
        }

        public void Login(string username, string password, string code)
        {
            var request = new ApiRequest($"{_host}/login", contentType: "application/x-www-form-urlencoded; charset=UTF-8", method: RestSharp.Method.Post);
            request.AddBody(ConvertToQueryString(new
            {
                userName = JsEncryptHelper.Encrypt(username, GlobalContext.PublicKey),
                dxCode = "000000",
                loginveri = "",
                password = JsEncryptHelper.Encrypt(password, GlobalContext.PublicKey),
                verifyCode = JsEncryptHelper.Encrypt(code, GlobalContext.PublicKey),
                rememberMe = false
            }));
            request.AddCookies(_cookieCollection);
            var ret = request.Invoke();
            if (!ret.IsSuccess) return;

            var obj = Newtonsoft.Json.JsonConvert.DeserializeObject<LoginOutput>(ret.Data);
            if (obj?.Success == true)
            {
                _cookieCollection = request.Client.Options.CookieContainer.GetAllCookies();
                return;
            }
            throw new Exception(obj.Error);
        }

        public Image GetCode()
        {
            var request = new ApiRequest($"{_host}/CodeVerifyImage?{new Random().NextDouble()}");
            var ret = request.InvokeImage();
            if (ret.IsSuccess) _cookieCollection = request.Client.Options.CookieContainer.GetAllCookies();
            return ret.Data;
        }

        private string ConvertToQueryString(object obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            var properties = obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
                .Where(p => p.CanRead);

            var keyValuePairs = properties.Select(p =>
            {
                var value = p.GetValue(obj);
                if (value == null) return $"{HttpUtility.UrlEncode(p.Name)}=";

                var stringValue = value is DateTime dateTimeValue ? dateTimeValue.ToString("o") : value.ToString();
                return $"{HttpUtility.UrlEncode(p.Name.ToLowerFirstChar())}={HttpUtility.UrlEncode(stringValue)}";
            });

            return string.Join("&", keyValuePairs);
        }
    }

    public class PromotionListOutput
    {
        /// <summary>
        /// 
        /// </summary>
        public int? id { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? ownerId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? estateId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? discountType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? discount { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? eventStartTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? eventEndTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? status { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? limitType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? cycleType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? createUserId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? inTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? updateTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? cycles { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? userRelations { get; set; }
        /// <summary>
        /// 时代品格1号
        /// </summary>
        public string? estateName { get; set; }
    }

    public class PromotionUserListInput : PageInput
    {
        public long promotionId { get; set; }
    }

    public class PromotionUserListOutput
    {
        public long id { get; set; } = 1;
        public long promotionId { get; set; }
        public int? type { get; set; }
        public string? value { get; set; }
        public long? estateId { get; set; }
    }

    public class PromotionListInput : PageInput
    {
        public int ownerId { get; set; }
        public string? estateId { get; set; }
        public string? limitType { get; set; }
        public string? estateId1 { get; set; }
        public int? discountType { get; set; }
        public string? eventDateRange { get; set; }
    }

    public class VehicleListInput: PageInput
    {
        public int ownerId { get; set; }
        public string userId { get; set; }
        public string licenseNum { get; set; }
        public int? queryType { get; set; }
        public string queryValue { get; set; }
    }

    public class VehicleInfoOutput
    {
        public long id { get; set; }
        public string licenseNum { get; set; }
        public string phone { get; set; }
        public string userId { get; set; }
        public string userName { get; set; }
        public string vehicleTypeName { get; set; }
        public string vehicleVinCode { get; set; }
        public string inTime { get; set; }
        public string updateTime { get; set; }
        public string bindTime { get; set; }
    }

    public class UserListInput: PageInput
    {
        public int ownerId { get; set; }
        public string dateRange { get; set; }
        public string packageType { get; set; }
        public string areaId { get; set; }
        public string estateId { get; set; }
        public string isCount { get; set; }
        public string cardType { get; set; }
        public int queryType { get; set; }
        public string queryValue { get; set; }
        public string statusDecide { get; set; }
    }

    public class UserInfoOutput
    {
        public long id { get; set; }
        public string userName { get; set; }
        public int level { get; set; }
        public string phone { get; set; }

        public string inTime { get; set; }
    }

    public class UserInfoInput: PageInput
    {
        public string userIdList { get; set; } = "[-1]";
        public int queryType { get; set; }
        public string queryValue { get; set; }
        public int ownerId { get; set; }
    }

    public class LoginOutput
    {
        public int? Code { get; set; }

        public string? Error { get; set; }

        public object? Data { get; set; }

        public bool Success { get; set; }
    }

    public class PageInput
    {
        public int page { get; set; } = 1;
        public int limit { get; set; } = 50;
        public int? fromPage  { get; set; }
        public long? leastTotal { get; set; }
        public string? deepPageTokenArr { get; set; }
    }

    public class CommonOutput
    {
        public int? Code { get; set; }

        public string? Msg { get; set; }

        public OtherMap OtherMap { get; set; }
    }

    public class OtherMap
    {
        public string deepPageToken { get; set; }
    }

    public class QueryOutputT<T> : CommonOutput
    {
        public int Count { get; set; }

        public T? Data { get; set; }
    }

    public class OrderQueryInput : PageInput
    {
        public string userPhone { get; set; } = "15934945766";
        public string dateRange { get; set; } = $"{DateTime.Now.ToString("yyyy-MM-01")} ~ {Convert.ToDateTime(DateTime.Now.AddMonths(1).ToString("yyyy-MM-01")).AddDays(-1).ToString("yyyy-MM-dd")}";
        public string? orderId { get; set; }
        public string? deviceId { get; set; }
        public string? simId { get; set; }
        public int? orderType { get; set; }
        public int? ownerId { get; set; }
        public string? payType { get; set; }
        /// <summary>
        /// 交易状态
        /// </summary>
        public string? isCount { get; set; }
        /// <summary>
        /// 充电状态
        /// </summary>
        public string? status { get; set; }
        public string? areaId { get; set; }
        public string? sysUserId { get; set; }
        public string? estateId { get; set; }
        public string? chargeMethod { get; set; }
        public string? searchEstateId { get; set; }
        public string? userIdOrUserCardId { get; set; }
        public string? payWay { get; set; }
    }

    public enum PromotionStatus
    {
        [Description("停用")]
        Block = 0,

        [Description("正常")]
        Normal = 1,
    }

    public enum LimitType
    {
        [Description("不限定")]
        Unlimit = 0,

        [Description("限定人员")]
        Limit = 1,
    }

    public enum DiscountType
    {
        [Description("免费")]
        Free = 0,

        [Description("折扣")]
        Discount = 1,
    }

    public enum VehicleQueryType
    {
        [Description("电卡卡号")]
        Card = 1,

        [Description("VIN")]
        VIN = 2,
    }

    public enum QueryType
    {
        [Description("用户编号")]
        ID = 1,

        [Description("手机号")]
        Phone = 2,

        [Description("电卡卡号")]
        Card = 5
    }

    public enum OrderType
    {
        [Description("充电订单")]
        ChargingOrder = 0,

        [Description("门禁订单")]
        AccessControlOrder = 1,

        [Description("超时占用订单")]
        OvertimeOccupancyOrder = 2,

        [Description("月卡购买续费")]
        MonthlyCardRenewal = 3,

        [Description("充电金兑换余额订单")]
        ChargingBalanceExchange = 4,

        [Description("中电联")]
        ChinaElectricityUnion = 5,

        [Description("超时占用补款订单")]
        OvertimeOccupancySupplement = 6,

        [Description("充电卡购买续费")]
        ChargingCardRenewal = 7
    }

    public enum PayType
    {
        [Description("刷卡")]
        CardSwipe = 1,

        [Description("网络支付")]
        OnlinePayment = 2,

        [Description("网络投币")]
        OnlineCoin = 3,

        [Description("线下投币")]
        OfflineCoin = 4,

        [Description("密码")]
        Password = 6
    }

    public enum PayWay
    {
        [Description("微信充值余额")]
        WeChatRecharge = 1,

        [Description("微信赠送余额")]
        WeChatGift = 2,

        [Description("支付宝充值余额")]
        AlipayRecharge = 3,

        [Description("支付宝赠送余额")]
        AlipayGift = 4,

        [Description("月卡支付")]
        MonthlyCard = 5,

        [Description("微信支付")]
        WeChatPay = 6,

        [Description("支付宝支付")]
        AlipayPay = 7,

        [Description("线下投币")]
        OfflineCoin = 8,

        [Description("商户微信充值余额")]
        MerchantWeChatRecharge = 9,

        [Description("商户微信赠送余额")]
        MerchantWeChatGift = 10,

        [Description("商户微信充值余额")]
        MerchantWeChatRecharge2 = 11,

        [Description("商户微信充值余额")]
        MerchantWeChatRecharge3 = 12,

        [Description("优惠券")]
        Coupon = 13,

        [Description("翼支付")]
        BestPay = 16,

        [Description("翼支付充值余额")]
        BestPayRecharge = 14,

        [Description("翼支付赠送余额")]
        BestPayGift = 15,

        [Description("商户翼支付充值余额")]
        MerchantBestPayRecharge = 17,

        [Description("商户翼支付赠送余额")]
        MerchantBestPayGift = 18,

        [Description("工行支付")]
        ICBCPay = 19,

        [Description("汇付支付")]
        HuiFuPay = 20,

        [Description("企业余额支付")]
        EnterpriseBalance = 23,

        [Description("一卡通刷卡支付")]
        CardSwipe = 24,

        [Description("建行支付")]
        CCBPay = 26,

        [Description("充电金兑换余额")]
        ChargingBalanceExchange = 27,

        [Description("一网通支付")]
        OneNetPay = 30,

        [Description("农行掌银APP")]
        ABCApp = 33,

        [Description("京东支付")]
        JDPay = 34,

        [Description("充电卡余额")]
        ChargingCardBalance = 35
    }

    /// <summary>
    /// 交易状态
    /// </summary>
    public enum OrderStatus
    {
        [Description("扣款订单")]
        DeductionOrder = 0,

        [Description("不统计订单")]
        NonCountedOrder = 1,

        [Description("退款订单")]
        RefundOrder = 2
    }

    /// <summary>
    /// 充电状态
    /// </summary>
    public enum StatusType
    {
        [Description("未付款")]
        Unpaid = 0,

        [Description("付款未充电/付款未开门")]
        PaidNotCharging = 1,

        [Description("充电中")]
        Charging = 2,

        [Description("充电结束/开门成功")]
        ChargingEnded = 3,

        [Description("叠加结束")]
        OverlayEnded = 5,

        [Description("待启动")]
        PendingStart = 6,

        [Description("取消预约")]
        AppointmentCancelled = 7
    }

    public enum EndType
    {
        [Description("已结束")]
        Ended = 0,

        [Description("计时结束")]
        TimerEnded = 1,

        [Description("充满结束")]
        FullyCharged = 2,

        [Description("手动结束")]
        ManualEnded = 3,

        [Description("功率过大")]
        OverPower = 4,

        [Description("空载结束")]
        NoLoadEnded = 5,

        [Description("充电结束")]
        ChargingEnded = 6,

        [Description("保险丝故障")]
        FuseFault = 7,

        [Description("未连接电枪")]
        GunNotConnected = 8,

        [Description("叠加结束")]
        OverlayEnded = 9,

        [Description("余额不足")]
        InsufficientBalance = 10,

        [Description("指令超时")]
        CommandTimeout = 11,

        [Description("时长超限")]
        TimeLimitExceeded = 12,

        [Description("温度过高")]
        OverTemperature = 13,

        [Description("电表异常")]
        MeterAbnormal = 14,

        [Description("负载异常-电压过高")]
        OverVoltage = 15,

        [Description("负载异常-触发漏保")]
        LeakageProtectionTriggered = 16,

        [Description("设备故障")]
        DeviceFault = 17,

        [Description("通道故障，灭火器触发")]
        FireExtinguisherTriggered = 18,

        [Description("烟感报警")]
        SmokeAlarm = 19,

        [Description("未关门结束订单")]
        DoorNotClosed = 20,

        [Description("浸水报警")]
        WaterImmersionAlarm = 21,

        [Description("用户手动停止充电")]
        ManualStopped = 51,

        [Description("输出不可控")]
        OutputUncontrollable = 52,

        [Description("SOC达到设定值")]
        SOCReached = 53,

        [Description("单体电池电压达到设定值")]
        SingleCellVoltageReached = 54,

        [Description("连接器过温")]
        ConnectorOverTemperature = 55,

        [Description("连接器故障")]
        ConnectorFault = 56,

        [Description("充电电压异常")]
        ChargingVoltageAbnormal = 57,

        [Description("DC20通信失败")]
        DC20CommunicationFailed = 58,

        [Description("RC10通信失败")]
        RC10CommunicationFailed = 59,

        [Description("电度表通信中断")]
        MeterCommunicationInterrupted = 60,

        [Description("输入过压")]
        InputOverVoltage = 61,

        [Description("输入缺相")]
        InputPhaseLoss = 62,

        [Description("内部过温")]
        InternalOverTemperature = 63,

        [Description("输出欠压")]
        OutputUnderVoltage = 64,

        [Description("熔断器故障")]
        FuseFault2 = 65,

        [Description("输出短路")]
        OutputShortCircuit = 66,

        [Description("电流采样异常")]
        CurrentSamplingAbnormal = 67,

        [Description("绝缘故障")]
        InsulationFault = 68,

        [Description("充电枪过温")]
        GunOverTemperature = 69,

        [Description("余额不足")]
        InsufficientBalance2 = 70,

        [Description("达到设定时间/金额/电量")]
        TimerEnded2 = 71,

        [Description("过电量保护")]
        OverEnergyProtection = 72,

        [Description("后台通信异常")]
        BackgroundCommunicationAbnormal = 73,

        [Description("充电机处于手动状态")]
        ChargerManualState = 74,

        [Description("车内接触器粘连")]
        ContactorAdhesion = 75,

        [Description("充电枪断开")]
        GunDisconnected = 76,

        [Description("输出过流")]
        OutputOverCurrent = 77,

        [Description("输出过压")]
        OutputOverVoltage = 78,

        [Description("电池总电压达到设定值")]
        TotalBatteryVoltageReached = 79,

        [Description("电池过温")]
        BatteryOverTemperature = 80,

        [Description("模块通讯故障")]
        ModuleCommunicationFault = 81,

        [Description("紧急停机")]
        EmergencyStop = 82,

        [Description("柜门打开")]
        CabinetDoorOpen = 83,

        [Description("枪加锁失败")]
        GunLockFailed = 84,

        [Description("充电机启动超时")]
        ChargerStartTimeout = 85,

        [Description("车辆BMS异常")]
        BMSAbnormal = 86,

        [Description("输出开关断开")]
        OutputSwitchDisconnected = 87,

        [Description("电流过于小")]
        CurrentTooSmall = 88,

        [Description("接地故障")]
        GroundFault = 89,

        [Description("主从机通信断开")]
        MasterSlaveCommunicationDisconnected = 90,

        [Description("网络断线")]
        NetworkDisconnected = 91,

        [Description("电表电能异常值")]
        MeterEnergyAbnormal = 92,

        [Description("车辆主动终止充电")]
        BMSActiveTermination = 93,

        [Description("连接故障cc跳变")]
        CCJumpFault = 95,

        [Description("电池反接")]
        BatteryReverseConnection = 96,

        [Description("防雷器告警停止")]
        SurgeProtectorAlarm = 98,

        [Description("电子锁未锁")]
        ElectronicLockNotLocked = 99,

        [Description("屏幕停止")]
        ScreenStopped = 100,

        [Description("刷卡停止")]
        CardSwipeStopped = 101,

        [Description("单体蓄电池电压过高")]
        SingleBatteryOverVoltage = 102,

        [Description("单体蓄电池电压过低")]
        SingleBatteryUnderVoltage = 103,

        [Description("整车蓄电池SOC过高")]
        VehicleBatterySOCHigh = 104,

        [Description("动力蓄电池充电过流")]
        PowerBatteryOverCurrent = 105,

        [Description("整车蓄电池SOC过低")]
        VehicleBatterySOCLow = 106,

        [Description("动力蓄电池充电过流")]
        PowerBatteryOverCurrent2 = 107,

        [Description("动力蓄电池充电过温")]
        PowerBatteryOverTemperature = 108,

        [Description("动力蓄电池绝缘异常")]
        PowerBatteryInsulationFault = 109,

        [Description("动力蓄电池组输出连接器异常")]
        PowerBatteryConnectorFault = 110,

        [Description("BMS达到设定总电压")]
        BMSTotalVoltageReached = 111,

        [Description("BMS达到单体电压设定值")]
        BMSSingleVoltageReached = 112,

        [Description("BMS绝缘异常")]
        BMSInsulationFault = 113,

        [Description("BMS连接器过温")]
        BMSConnectorOverTemperature = 114,

        [Description("BMS元件过温")]
        BMSComponentOverTemperature = 115,

        [Description("BMS连接器故障")]
        BMSConnectorFault = 116,

        [Description("BMS电池组过温")]
        BMSBatteryOverTemperature = 117,

        [Description("BMS高压继电器故障")]
        BMSRelayFault = 118,

        [Description("BMS监测点2电压异常")]
        BMSMonitoringPoint2VoltageAbnormal = 119,

        [Description("BMS其它故障")]
        BMSOtherFault = 120,

        [Description("BMS报电流过大的停止充电")]
        BMSOverCurrentStop = 121,

        [Description("BMS报电压异常的停止充电")]
        BMSOverVoltageStop = 122,

        [Description("充满结束")]
        FullyCharged2 = 123,

        [Description("未插好充电枪")]
        GunNotPluggedIn = 124,

        [Description("绝缘检测超时")]
        InsulationDetectionTimeout = 125,

        [Description("绝缘检测异常")]
        InsulationDetectionAbnormal = 126,

        [Description("充电机暂停服务")]
        ChargerSuspended = 127,

        [Description("充电机系统故障，不能充电")]
        ChargerSystemFault = 128,

        [Description("辅电不匹配")]
        AuxiliaryPowerMismatch = 129,

        [Description("辅电开启失败")]
        AuxiliaryPowerStartFailed = 130,

        [Description("充电启动超时")]
        ChargingStartTimeout = 131,

        [Description("BMS通信握手失败")]
        BMSHandshakeFailed = 132,

        [Description("BMS通信配置失败")]
        BMSConfigurationFailed = 133,

        [Description("BMS参数异常")]
        BMSParameterAbnormal = 134,

        [Description("桩正在充电中，不能再启动")]
        ChargerBusy = 135,

        [Description("启动未知错误")]
        UnknownStartError = 136,

        [Description("电池反接")]
        BatteryReverseConnection2 = 137,

        [Description("请重新插拔枪")]
        ReplugGun = 138,

        [Description("枪未插好")]
        GunNotReady = 150,

        [Description("强制结束")]
        ForcedEnd = 200
    }

    public class UserChargerConfig
    {
        /// <summary>
        /// 
        /// </summary>
        public int minWatt { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int maxWatt { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int idleTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int fullTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int refundTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int unusualTime { get; set; }
    }

    public class OrderQueryOutput
    {
        /// <summary>
        /// 
        /// </summary>
        public int? id { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? tmpId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? userId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? portNum { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? status { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? type { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? payEntrance { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? purchaseType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? payType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? cardId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? orderNum { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? sordNo { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? ownerId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? workTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? electricQuantity { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? actualElectricQuantity { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? originalElectric { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? originalPrice { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? payPrice { get; set; }
        /// <summary>
        /// , [实时计费订单，原价：0.0]
        /// </summary>
        public string? discountDetail { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? provinceId { get; set; }
        /// <summary>
        /// 内蒙古自治区
        /// </summary>
        public string? provinceName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? cityId { get; set; }
        /// <summary>
        /// 通辽市
        /// </summary>
        public string? cityName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? countyId { get; set; }
        /// <summary>
        /// 奈曼旗
        /// </summary>
        public string? countyName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? estateId { get; set; }
        /// <summary>
        /// 时代品格1号
        /// </summary>
        public string? estateName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? deviceId { get; set; }
        /// <summary>
        /// 品格_1号机
        /// </summary>
        public string? deviceName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? inTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? updateTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? thirdNum { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? isCount { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? payWay { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? payBank { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? actualTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? balance { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? refundRecheck { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? priceInfoType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? userSelectPriceType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? priceType { get; set; }
        /// <summary>
        /// Json
        /// </summary>
        public string? priceDetail { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? overPriceDetail { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? priceBefore { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? priceEndDetail { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? endType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? paymentPrice { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? chargeType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? isAdvanceReceive { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? realTimeCharge { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? refundType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? sysUserId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? factory { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? deviceType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? deviceFamily { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? userChargingRecordList { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? powerType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? isStackEndOrder { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? stackEndOrderNum { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? stackEndOrders { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? thisOrderInTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? thisOrderInTimeName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? isUseCoupon { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? couponVO { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? detailOfAmountCalculation { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? simId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? overPower { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? orderType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? limitTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? limitCount { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? currentCount { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? stackBeforeMoney { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? vinNum { get; set; }
        /// <summary>
        /// Json
        /// </summary>
        public string? electricDetail { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? totalElectricMoney { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? totalServiceFee { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? settlementType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? thirdPlatformId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? thirdServicePlatformId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? userCarCardId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? peakPlainValley { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? payChannel { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? orderWay { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? sxfUuid { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? thirdMno { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? balanceDeductionStatus { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? estatePaymentStatus { get; set; }
        /// <summary>
        /// Json
        /// </summary>
        public string? settlementRelationInfo { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? odwReason { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? ledgerProcess { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? clearDate { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? odFee { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? odNetFee { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? odBlceFee { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public UserChargerConfig? userChargerConfig { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? userCarChargingLatelyInfo { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? payInitialEntrance { get; set; }
        /// <summary>
        /// 江西驴充充物联网科技有限公司
        /// </summary>
        public string? ownerName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? insurance { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? chargeInsuranceType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? insurancePrice { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? insuranceFee { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? totalPaymentPrice { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? invoiceFlag { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? invoiceOrderNo { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? isInvoiced { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? userPhone { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? occupyOrderNumber { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? newCouponAmount { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? newCouponUserRecordId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? newCouponPaymentAmount { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? sxfActualPaymentAmount { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? balancePayRecordJson { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? balanceRefundRecord { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? payScore { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? businessType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? packageType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? mediaEntrance { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? mineCarId { get; set; }
        /// <summary>
        /// 蒙GF73687
        /// </summary>
        public string? licenseNum { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? showInsuranceReport { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? corporateId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? chargeFailType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? serviceModelType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? advRecElectricMoney { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? advRecServiceFee { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? subsidyPrice { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? subsidyTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? chargeInsuranceLedgerPrice { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? discountFlag { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? discount { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? beforeDiscountPrice { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? beforeDiscountTotalServiceFee { get; set; }
        /// <summary>
        /// Json
        /// </summary>
        public string? carServicePromotionDetail { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? tag { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? preChargeFlag { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? insuranceCouponMoney { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? insuranceCouponRecordId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? insuranceDeductionPrice { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? isMerchantBears { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int? chargeOrderSource { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? realPayAmount { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? chargeInsuranceRefundTag { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? frequencyType { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? paymentCallBackTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? freeTryJson { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? isRefund { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? ledgerStatus { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? appChannelMessage { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? channelMessage { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? chargeMethod { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? appointmentTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? appointmentChargeConfigId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? appointmentChargeBeginTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? appointmentChargeEndTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? ledgerAccountFlag { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? isShare { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? ledgerClearDate { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? actualTimeSeconds { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? customerOrder { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? electricOrder { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? powerOrder { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? fullBlackoutOrder { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public double? bigIntegerId { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? actualMillisecondWorkTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? actualMinuteWorkTime { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? timeOver { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? freeTry { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string? stop { get; set; }
    }
}
